package base.day22.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Stream;

public class MyStream2 {
    public static void main(String[] args) {
        //单列集合
        method1();
        //双列集合
        method2();
        //数组
        method3();
        //同种数据类型的多个数据
        method4();
    }

    private static void method4() {
        //同种数据类型的多个数据
        Stream.of(1,2,3,4,5,6,7,8).forEach(s-> System.out.println(s));
    }

    private static void method3() {
        //数组
        int[] arr={1,2,3,4,5};
        Arrays.stream(arr).forEach(s-> System.out.println(s));
        System.out.println("----------------------------------");
    }

    private static void method2() {
        //双列集合
        HashMap<String,Integer> map=new HashMap<>();
        map.put("zhangsan",23);
        map.put("lisi",24);
        map.put("wangwu",25);
        map.put("qinqi",27);
        //keyset方法
        map.keySet().stream().forEach(s-> System.out.println(s));
        System.out.println("--------------------------------------");
        //entryset方法
        map.entrySet().stream().forEach(s-> System.out.println(s));
        System.out.println("--------------------------------------");
    }

    private static void method1() {
        //单列集合
        ArrayList<String> list=new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");

        list.stream().forEach(s-> System.out.println(s));
        System.out.println("------------------------------");
    }
}
